package com.eagledata.project.business.memberInfo.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.eagledata.common.utils.StringUtil;
import com.eagledata.project.business.memberInfo.mapper.MemberInfoMapper;
import com.eagledata.project.business.memberInfo.domain.MemberInfo;
import com.eagledata.project.business.memberInfo.service.IMemberInfoService;

/**
 * 会员 服务层实现
 * 
 * @author eagledata
 * @date 2018-06-25
 */
@Service
public class MemberInfoServiceImpl implements IMemberInfoService 
{
	@Autowired
	private MemberInfoMapper memberInfoMapper;
	
	/**
     * 查询会员信息
     * 
     * @param id 会员ID
     * @return 会员信息
     */
	 @Override
	public MemberInfo selectMemberInfoById(Integer id) {
	    return memberInfoMapper.selectMemberInfoById(id);
	}
	
	/**
     * 查询会员列表
     * 
     * @param memberInfo 会员信息
     * @return 会员集合
     */
	 @Override
	public List<MemberInfo> selectMemberInfoList(MemberInfo memberInfo) {
	    return memberInfoMapper.selectMemberInfoList(memberInfo);
	}
	
    /**
     * 新增会员
     * 
     * @param memberInfo 会员信息
     * @return 结果
     */
	 @Override
	public int insertMemberInfo(MemberInfo memberInfo) {
	    return memberInfoMapper.insertMemberInfo(memberInfo);
	}
	
	/**
     * 修改会员
     * 
     * @param memberInfo 会员信息
     * @return 结果
     */
	 @Override
	public int updateMemberInfo(MemberInfo memberInfo) {
	    return memberInfoMapper.updateMemberInfo(memberInfo);
	}
	
	/**
     * 保存会员
     * 
     * @param memberInfo 会员信息
     * @return 结果
     */
	 @Override
	public int saveMemberInfo(MemberInfo memberInfo) {
	    Integer id = memberInfo.getId();
		int rows = 0;
		if (StringUtil.isNotNull(id)) {
		    rows = memberInfoMapper.updateMemberInfo(memberInfo);
		} else {
		    rows = memberInfoMapper.insertMemberInfo(memberInfo);
		}
		return rows;
	}
	
	/**
     * 删除会员信息
     * 
     * @param id 会员ID
     * @return 结果
     */
	 @Override
	public int deleteMemberInfoById(Integer id) {
	    return memberInfoMapper.deleteMemberInfoById(id);
	}
	
	/**
     * 批量删除会员对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteMemberInfo(Integer[] ids) {
		return memberInfoMapper.batchDeleteMemberInfo(ids);
	}
	
}
